﻿namespace WMS6.Web.Administration
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class AuditQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnSearch;
        protected CheckBox cbxDelete;
        protected CheckBox cbxInsert;
        protected CheckBox cbxUpdate;
        protected DropDownList ddlColName;
        protected DropDownList ddlCreateBy;
        protected DropDownList ddlEndTime;
        protected DropDownList ddlPrimaryKey;
        protected DropDownList ddlStartTime;
        protected DropDownList ddlTableName;
        protected HtmlForm F1220;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img2;
        protected HtmlImage img3;
        protected Label lblCareateBy;
        protected Label lblColName;
        protected Label lblCreateWh;
        protected Label lblEndTime;
        protected Label lblPrimaryKey;
        protected Label lblStartTime;
        protected Label lblTableName;
        protected HtmlLink mycss;
        protected TextBox txtCareateBy;
        protected TextBox txtColName;
        protected TextBox txtEndTime;
        protected TextBox txtEndTime2;
        protected TextBox txtPrimaryKey;
        protected TextBox txtStartTime;
        protected TextBox txtStartTime2;
        protected TextBox txtTableName;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("AuditList.aspx?action={0}&from=list", this.hdnActionID.Value.Trim()), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("AuditList.aspx?action={0}", this.hdnActionID.Value.Trim()), false);
        }

        private void InitDropDownList()
        {
            base.InitQueryDDL(this.ddlTableName, 0);
            base.InitQueryDDL(this.ddlCreateBy, 0);
            base.InitQueryDDL(this.ddlColName, 0);
            base.InitQueryDDL(this.ddlPrimaryKey, 0);
            base.InitQueryDDL(this.ddlStartTime, 1);
            base.InitQueryDDL(this.ddlEndTime, 1);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownList();
            }
        }

        public string ColName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtColName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtColName.Text.Trim(), this.ddlColName.SelectedValue);
                }
                return "";
            }
        }

        public string CreateBy
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCareateBy.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCareateBy.Text.Trim(), this.ddlCreateBy.SelectedValue);
                }
                return "";
            }
        }

        public string Delete
        {
            get
            {
                if (this.cbxDelete.Checked)
                {
                    return "Y";
                }
                return "";
            }
        }

        public string EndTime
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
                {
                    return base.GetParamsString(this.txtEndTime.Text.Trim(), this.ddlEndTime.SelectedValue, this.txtEndTime2.Text.Trim(), "EndTime");
                }
                return "";
            }
        }

        public string Insert
        {
            get
            {
                if (this.cbxInsert.Checked)
                {
                    return "Y";
                }
                return "";
            }
        }

        public string PrimaryKey
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPrimaryKey.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPrimaryKey.Text.Trim(), this.ddlPrimaryKey.SelectedValue);
                }
                return "";
            }
        }

        public string StartTime
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()))
                {
                    return base.GetParamsString(this.txtStartTime.Text.Trim(), this.ddlStartTime.SelectedValue, this.txtStartTime2.Text.Trim(), "StartTime");
                }
                return "";
            }
        }

        public string TableName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtTableName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtTableName.Text.Trim(), this.ddlTableName.SelectedValue);
                }
                return "";
            }
        }

        public string Update
        {
            get
            {
                if (this.cbxUpdate.Checked)
                {
                    return "Y";
                }
                return "";
            }
        }
    }
}

